package thread;

class MyThread extends Thread {

    /**
     * 重写父类的方法
     * @Override 提示编译器，进行更严格的检查
     */
    @Override
    public void run() {
        //这里写的代码，就是该线程要完成的工作
        while(true){
            System.out.println("hello thread");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}

public class Demo01 {
    public static void main(String[] args) {
        Thread t = new MyThread();
        t.start();
        while(true){
            System.out.println("hello main");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
